Skip to content

Instantly share code, notes, and snippets.

@jesstelford
Last active April 4, 2020 17:52
Show Gist options
  • Save jesstelford/eded5fe8c2611f332648 to your computer and use it in GitHub Desktop.
Save jesstelford/eded5fe8c2611f332648 to your computer and use it in GitHub Desktop.
Netflix on Raspberry Pi (incomplete)

Note: as @clibois mentioned below, due to the DRM Netflix uses, all decoding has to be done in CPU, making it somewhat choppy.

Note 2: Even the RPi 3 suffers from these CPU limitations. There is the potentially risky option of overclocking your RPi 3, but I haven't tried this.

If you manage to get smooth playback, please contact me, or post your solution here

UPDATE: I can no longer get this method to work. I have tried using Chromium v47, and v48, and both result in Netflix error "Oops, something went wrong" / C7053-1807, for which I can find no description online. If you manage to get things up and running, please contact me!

OSMC

These steps are based on OSMC, which in turn is based on a Debian Jessie + Kodi install, so should be the same for any Debian based setup.

For the quickest setup, install the latest OSMC

Preparation

Create a working folder

We'll use this directory to store our temporary downloads, etc.

mkdir netflix
cd netflix

Update the RPi

Note: for all the commands below, I suggest switching into Super User mode to avoid typing sudo before every command:

sudo su

Let's start by making sure everything is up to date:

apt-get update
apt-get upgrade

Chromium

This section is inspired by the instructions here

We need to grab Chromium v47 - v48 has a bug with netflix, and v49+ doesn't work on our Debian Jessie system.

  1. Visit the page for chromium-browser
  2. Scroll down to "The Vivid Vervet" and click that heading.
  3. Scroll down to the "Releases in Ubuntu" heading
  4. Find the highest version that starts with 47 (note: v48 does not work).
  5. Click the arrow next to it.
  6. Look for the Builds header on the right
  7. Click the "armhf" option.
  8. On the following page, scroll to the bottom to find the list of links under Built Files.

For each of the files that look like:

  • chromium-browser_*.deb
  • chromium-codecs-ffmpeg-extra_*.deb

(Note: You do not need the *-dbg*.deb or *-chromedriver*.deb versions of the packages)

For example, I grabbed these files:

We need to download them on the RPi:

wget -c https://launchpad.net/...

Next, install the ffmpeg deb with:

dpkg -i chromium-codecs*.deb

Now, install the dependencies:

apt-get install `dpkg -I chromium-browser*.deb | grep " Depends" | sed "s/^ Depends: //" | sed "s/ ([^)]\+)//g" | sed "s/ | [^ ]\+//g" | sed "s/,//g"`

This command essentially searches for the dependencies of the chromium-browser*.deb package, then installs them all.

Gotchyas

but it is not going to be installed

If you get any errors such as:

avr-libc : Depends: gcc-avr (>= 1:4.3.4) but it is not going to be installed

Then you need to run the following commands (This will fix all the broken dependencies, and re-configure all the previously broken packages.):

apt-get clean
apt-get install -f
dpkg --configure -a

Then re-run command above to install the dependencies.

libexif / lsb-release not installed

I also had to install libexif12 & lsb-release to get chromium running:

apt-get install libexif12 lsb-release

Now, install chromium:

dpkg -i chromium-browser*.deb

Set chromium to run correctly; edit the file /etc/chromium-browser/default to be (You can use vi or nano to edit the file):

CHROMIUM_FLAGS="-password-store=detect -user-data-dir"

Finally, setup a symlink so plugins, etc, that are searching for chrome will find chromium instead:

cd /usr/bin
ln -s chromium-browser chrome-browser
ln -s chromium-browser chrome
cd -

Audio

In order to have Chrome output its audio to HDMI, we need to setup the ALSA drivers:

apt-get install alsa-utils
modprobe snd_bcm2835
amixer cset numid=3 2

(the 2 at the end is to specify HDMI. Use 1 for headphones)

Window Manager

For Chrome to take advantage of the full screen, and to use the mouse, we need a window environment of some kind. Since OSMC doesn't come with one by default, let's install matchbox now:

apt-get install xorg xinit matchbox

Launching Chromium

If you're still root (because you ran sudo su as mentioned at the top), drop to your normal user now:

exit

Create a new file /home/osmc/.xinitrc (using vi or nano) with the contents:

#!/bin/bash
# ~/.xinitrc

xset -dpms
xset s off
xset s noblank

matchbox-window-manager &
chromium-browser http://www.netflix.com

kill $!

Make it executable with:

chmod a+x /home/osmc/.xinitrc

And now give permission to start up the script by editing the file /etc/X11/Xwrapper.config (may require being root again), and changing the allowed_users line to be:

allowed_users=anybody

Then to test, ensure you can see OSMC up and running on whatever display you have the rPi connected to, make sure you're not root, then run the following command:

sudo systemctl stop mediacenter && xinit /home/osmc/.xinitrc && sudo systemctl start mediacenter

This will shut-down OSMC and pop up Chromium. To go back to OSMC, use the Chromium shortcut to close the current window: <ctrl>-w (or if you have a mouse, simply click the "x" to close the window).

Note: The first time you run the above command it may display a black screen for 30-60 seconds before displaying Chromium. Subsequent executions should show Chromium within 1-2 seconds of OSMC shutting down.

Note: If you see errors such as [1:1:0326/155000:ERROR:image_metadata_extractor.cc(112)] Couldn't load libexif., then you can install the missing dependency like so:

sudo apt-get install libexif12

Playing Netflix in Chromium

Netflix requires libnss3 (already installed as a dependency of chromium-*.deb above), and the widevine DRM plugin.

Prior to Chromium v44, widevine would only work with official Google Chrome (which doesn't work on the RPi's ARM-based CPU). However, from 44 onwards, a patch has been added to allow the widevine plugin to work.

Getting widevine working

Thanks to @ who managed to get it working!

Obtain widevine plugin

Thanks to Google's ARM ChromeOS builds, we can get a working copy of the widevine plugin to run on our RPi.

Still on the RPi:

wget https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_7077.134.0_daisy-skate_recovery_stable-channel_skate-mp.bin.zip
unzip chromeos*.zip

Then we want to get access to the files stored on that ChromeOS image:

sudo apt-get install kpartx
sudo kpartx -avs chromeos*.bin

You will see the following output where it has created a series of partitions, representing the Chromebook disk image:

add map loop0p1 (254:0): 0 28672 linear /dev/loop0 2928640
add map loop0p2 (254:1): 0 32768 linear /dev/loop0 20480
add map loop0p3 (254:2): 0 2641920 linear /dev/loop0 286720
add map ...

We're interested in the one ending in p3, which will now exist at /dev/mapper/loop0p3. Let's mount it:

sudo mkdir -p /media/osmc/chromeos
sudo mount -t ext2 /dev/mapper/loop0p3 -o ro /media/osmc/chromeos/

Now move into the root of that partition and search for the widevine plugins:

cd /media/osmc/chromeos/
find ./ -type f -name "libwidevine*"

The two files you want are named libwidevinecdm.so and libwidevinecdmadapter.so (ignore any "Permission denied" errors).

sudo cp <path_to_files>/libwidevine*.so /usr/lib/chromium-browser/

(replace <path_to_files> with the location returned from the find command above)

Controlling Chromium

Before we continue, we need a way to control Chromium. Let's do it with our phone!

Grab the app Home Remote Control.

Install xdotool on the RPi:

apt-get install xdotool

In Home Remote Control, select "Linux only" and enter your RPi's IP address, as well as the user / pass combo to log into SSH (default is: osmc/osmc).

Tricking Netflix into executing widevine

Fire up Chromium again:

sudo systemctl stop mediacenter && xinit /home/osmc/.xinitrc && sudo systemctl start mediacenter

Once Chromium is loaded up, install the "User Agent Switcher" extension from the Play Store, then add the following user agent as "Chrome":

Mozilla/5.0 (X11; CrOS armv7l 6946.63.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36

In the "User Agent Switcher" tool, set that as a permanent override for netflix.com.

Reload netflix.com, and you should now be able to start streaming!

Cleaning up

Shutdown your RPi:

sudo shutdown now

Then start it up again (this is a cheat's way of unmounting the ChromeOS image).

SSH back into your RPi, then remove the temporary folder we created at the start:

sudo rm -rf /home/osmc/netflix
@eliseurm
Copy link

Tell me why the topic of "Things that do not work" ??

They really will not really make netflix work?

@samuelengelking
Copy link

Hi,
I've got chromium installed and I get it started. But I can't get the widevine plugin to work. I'm using Chromium 48 on RPi 2.
Any ideas)

@Rudower
Copy link

Rudower commented Mar 1, 2016

Hi there. It's exactly the same thing and configuration on my side, and with this unsuccessful result as well. Please, help. Thanx beforehand. And my most sincere congratulations for a great technical article: it didn't turn out well in the first try, but definitely the article is thoroughly documented and lets the reader learn a lot in the process.

@Vik-Thor
Copy link

Vik-Thor commented Mar 4, 2016

hi, what do you use to execute the command line, I tried with Advenced Launcher Addon with '/bin/sh' and argument a shell script with "sudo systemctl stop mediacenter && xinit /home/osmc/.xinitrc && sudo systemctl start mediacenter" and it doesn't work;
can explain how do this, thanx a lot (netfoix doesn't work for me too, youtube very laggy (use Youtube addon) but have chromium on raspberry pi is very cool)

@thetrueavatar
Copy link

I don't know if everything will work but as I told here https://bugs.launchpad.net/ubuntu/+source/chromium-browser/+bug/1371274?comments=all
your user agent need to be : Mozilla/5.0 (X11; CrOS armv7l 6946.63.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2357.130 Safari/537.36
Otherwise you'll have some trouble saying that you have been disconnected from netflix(guess it's a multi-thread problem).
BTW there is a brand new raspbian distro which includes drivers for webgl acceleration by default. I don't know if OSMC is already base on that version but this could be nice.
I have tried the webgl acceleration on this new build(raspbian) but this was even slower than before...
EDIT: you have to acctivate the driver through rasp-config. This is working far better but rendering is still choppy and cpu high(80-90%).
I don't think webgl is correctly working as with https://www.chromeexperiments.com/webgl none of the experiment did work
Maybe I should try with chromium 48 but had no luck to install it due to missing dependencies
EDIT2: Had no luck neither on Chromium 48... Here is the error when trying to use webgl:
`[6486:6486:0313/122008:ERROR:gles2_cmd_decoder.cc(6795)] [GroupMarkerNotSet(crbug.com/242999)!:6868A858]GL ERROR :GL_INVALID_VALUE : glRenderbufferStorage: dimensions too large
[6486:6486:0313/122009:ERROR:gles2_cmd_decoder.cc(7613)] [GroupMarkerNotSet(crbug.com/242999)!:6868A858]RENDER WARNING: texture bound to texture unit 0 is not renderable. It maybe non-power-of-2 and have incompatible texture filtering.
unknown NIR ALU inst: vec1 ssa_287 = fddx ssa_202
Received signal 6
#0 0x000073cbbdf2 base::debug::StackTrace::StackTrace()
#1 0x000073cbc128
#2 0x0000721861a0
#3 0x000072184f70 gsignal

[end of stack trace]
[6425:6425:0313/122010:ERROR:gpu_process_transport_factory.cc(640)] Lost UI shared context.
[6669:6669:0313/122015:ERROR:gles2_cmd_decoder.cc(13718)] [.Offscreen-MainThread-0x58d49ee0]GL ERROR :GL_INVALID_OPERATION : glProduceTextureDirectCHROMIUM: unknown texture for target
[6425:6425:0313/122036:ERROR:navigation_entry_screenshot_manager.cc(140)] Invalid entry with unique id: 20
`

@thetrueavatar
Copy link

I have posted a message on the raspbian forum about webgl and netflix+chromium.
They say that h264 decoding using webgl is not feasible with netflix because of the drm used:
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=139939&p=927818#p927818
If that's true this is really bad news because playback is a complete mess due to cpu limitation.
Maybe that the raspberry pi 3 has the power to do the decoding only with the cpu....

@thetrueavatar
Copy link

For information, there are some chrome launcher plugin available in kodi:
forum.kodi.tv/showthread.php?tid=254263
I give it a try to see if we could have something directly from kodi.

@jesstelford
Copy link
Author

@clibois Thanks for the clarifications. Unfortunately I can no longer get Netflix to stream using my method above.

Did you manage to get this working recently? The only thing I can think of is you're using the stock Raspbian, where I'm using OSMC. Do you mind writing up your exact steps (if they differ from above) for myself and others to benefit from? Thanks :)

@samuelengelking
Copy link

Hi,
I am using OSMC. I followed your steps exactly. I only used a more current version of the recovery image. But haven't got it working

@thetrueavatar
Copy link

@jesstelford: I'm having some problem on raspbian since yesterday too(C7121 and M7121 netflix error). I have done the installation on osmc by following some of your steps. It used to work but will check if'ts still working...
EDIT: I have been able to play a movie on osmc with your instruction but rendering is glitchy. I already had the problem before but does'nt rember how to fix it. Maybe it's because I'm watching it through vlc. Will try on my tv when it's available
EDIT2: One way to overcome some weird problem with netflix is to clear i browser data specially cookies and cache data
EDIT3: I have upgarde my chromium to the last version available(49) but now I always get the C7121... Guess that netflix is very sensitive on the chromium version. Maybe I should upgrade my libwidevine plugin with the last version and check with the default user agent in chrome from chromeos

@thetrueavatar
Copy link

I had a lot of trouble to make it works on my raspbian. I have finally clean all my install of chromium and it works again:

  1. sudo apt-get purge chromium-browser
  2. rm -r /home/pi/.config/chromium
  3. I have reinstalled the version chromium-browser_45.0.2454.85-0ubuntu0.15.04.1.1181_armhf.deb + ffmpeg-extra
  4. Then I have copy the libwidevine*.so to /usr/lib/chromium from the https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_7077.134.0_daisy-skate_recovery_stable-channel_skate-mp.bin.zip
  5. I have set user agent to :
    Mozilla/5.0 (X11; CrOS armv7l 6946.63.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2357.130 Safari/537.36
  6. I have enabled the widevine plugin through chrome://plugins and set it to always run
    install kodi on raspbian(sudo apt-get install kodi). I hope I could make netflix working with flex2kodi plugin of kodi since there is an X server with raspbian....

@mboel
Copy link

mboel commented Apr 19, 2016

If you want it to work with a newer version of chromium-browser then extract the libwidevine*.so from a more recent version of the Samsung chromebook recovery image.
I got it to work by installing this version of chromium:
https://www.raspberrypi.org/forums/viewtopic.php?t=121195
and using this version of the recovery image:
https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_7834.60.0_daisy_recovery_stable-channel_snow-mp-v3.bin.zip

It is running pretty smooth on the pi 3 if you enable the experimental openGL driver. However it breaks CEC and the pi is getting very hot. :)

@thetrueavatar
Copy link

It is running pretty smooth on the pi 3 if you enable the experimental openGL driver. However it breaks CEC and the pi is getting very hot. :

Are you sure of this ? webgl basically allow to call opengl through javascript and is available in the last raspbian with the opengl driver but once again I was told that it should not improve performance. From what I have understood raspberry pi2 is not considered as a secure platform so drm won't allow gpu to do the decoding directly through webgl.

@mboel
Copy link

mboel commented Apr 20, 2016

Of cause you don't get hardware accelerated Netflix video by enabling the experimental openGL driver, that is why the Pi gets hot. Everything else that supports it gets rendered by the GPU. I suggest you try it.
However expect some trouble there is a reason why it is called experimental! It doesn't play well with Kodi, CEC and it is unstable!
You can also try to open chromium and go to
chrome://gpu
with and without the driver enabled.
It also work on the pi 2, but don't blow you resolution up to 1080p. I run 720p with a good result (Netflix streams video in 720x480).

@buma
Copy link

buma commented May 12, 2016

I was also successful with latest version of chromium (49) from https://www.raspberrypi.org/forums/viewtopic.php?t=121195 and this image: https://dl.google.com/dl/edgedl/chromeos/recovery/chromeos_7834.60.0_daisy_recovery_stable-channel_snow-mp-v3.bin.zip .

Netflix playback was really smooth. CPU and GPU is at 70°C. But during Netflix GUI it is at 75°C. When I disabled top panel in Netflix and used EGLS --use-gl=egl temperature dropped. Seems that GL ES is used for changing the size of posters on hover in Netflix UI since everything is smoother with this. But I have only SD Netflix package so video is much easier to decode.

Netflix worked only when started with different user agent:

chromium-browser --use-gl=egl --user-agent=”Mozilla/5.0 (X11; CrOS armv7l 6946.86.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36”

Those urls are useful when testing DRM:
Open https://shaka-player-demo.appspot.com/ and load a manifest that uses Widevine.
Open http://www.dash-player.com/demo/drm-test-area/, check whether the page says bitdash uses Widevine in your browser, then play the video.

Both worked and showed Widevine even before changing user agent but Netflix worked only with different user agent.

Usefull is also list of Chrome flags: http://peter.sh/experiments/chromium-command-line-switches/

@carneiru
Copy link

carneiru commented May 16, 2016

Someone could make a "dd " sdcard backup with a funtional Netflix and share? I don't know why these steps don't work for me, I'm using kodi instead osmc...

@silberzwiebel
Copy link

silberzwiebel commented May 23, 2016

Thanks for this tutorial. I was succesful to play netflix under OSMC in chromium with this and the chromium versions and libwidevine libraries mentioned in the comments from @buma and @mboel.
However, I do want to use netflix from within kodi and tried to use the flix2kodi addon that @clibois mentioned. To do so, I also installed lxde. Unfortunately, I am not able to switch to the chromium that flix2kodi succefully starts. That is, I hear the sound but do not see the video. Chromium is running, but Kodi stays on top of the display. I tried to plug in a keyboard and do an alt-tab, but this does not work. Apparently, kodi always runs in a fullscreen mode. All the workaround to get windowed mode of kodi do not work. If anybody has a hint to do this, I'd be very grateful.
I'm happy to provide a tutorial then, too.

@jolny
Copy link

jolny commented May 29, 2016

@silberzwiebel maybe you can find it by going through the screen sessions? Not sure if it'd work with Kodi, but in Ubuntu you can use Ctrl-Alt-F3 to get into a terminal. Or possibly Alt + -> (arrow key). If it works, you could check if you can find another screen session which contains Chromium.

@thetrueavatar
Copy link

thetrueavatar commented Jun 13, 2016

@silberzwiebel : I didn't succeed to mamakde it work but one hint for you is that I think that kodi with osmc doesn't use any X11 server. So what you see on the screen isn't something rendered by the X server. That would explain why you hear the sound but doesn't see the video. Don't know how to fix that though...

@fitiko
Copy link

fitiko commented Jul 10, 2016

Try with the v51 version of chromium. It might work according to this topic:

https://www.raspberrypi.org/forums/viewtopic.php?f=35&t=98559&sid=a5712aa35fbbbfad38594733ebb3df04&start=50

@hackwilleeuw
Copy link

hackwilleeuw commented Jul 12, 2016

Guide works 50% for me on osmc / ubuntu mate
1 problem.. video is all garbage.

& this is my first post on github.

@facundobianco
Copy link

facundobianco commented Aug 14, 2016

Following @fitiko's comment I installed the v51 version (from The Trusty Thar):

wget https://launchpad.net/ubuntu/+archive/primary/+files/chromium-browser_51.0.2704.79-0ubuntu0.14.04.1.1121_armhf.deb
wget https://launchpad.net/ubuntu/+archive/primary/+files/chromium-codecs-ffmpeg-extra_51.0.2704.79-0ubuntu0.14.04.1.1121_armhf.deb
wget http://ftp.us.debian.org/debian/pool/main/libg/libgcrypt11/libgcrypt11_1.5.0-5+deb7u4_armhf.deb
sudo apt-get install --no-install-recommends gconf-service libasound2 libatk1.0-0 libatomic1 libc6 libcairo2 \
    libcups2 libdbus-1-3 libexpat1 libfontconfig1 libfreetype6 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 \
    libgtk2.0-0 libnspr4 libnss3 libpam0g libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libstdc++6 \
    libx11-6 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 \
    libxtst6 zlib1g bash libnss3 xdg-utils libc6 libgcc1 zlib1g python-crypto
for NDEB in libgcrypt11_1.5.0-5+deb7u4_armhf.deb \
    ffmpeg-extra_51.0.2704.79-0ubuntu0.14.04.1.1121_armhf.deb \
    browser_51.0.2704.79-0ubuntu0.14.04.1.1121_armhf.deb
do sudo dpkg -i ${NDEB} ; done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment